﻿<%@ Page Title="" Language="C#" MasterPageFile="~/site.Master" AutoEventWireup="true" CodeBehind="QuanLyThuoc.aspx.cs" Inherits="QLHieuThuocFull.QuanLyThuoc" %>

<%@ Register Assembly="DevExpress.Web.v14.1, Version=14.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.v14.1, Version=14.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxFormLayout" TagPrefix="dx" %>

<%@ Register Assembly="DevExpress.Web.v14.1, Version=14.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxGridView.Export" TagPrefix="dx" %>
<%@ Register assembly="DevExpress.Web.v14.1, Version=14.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxGridView" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.v14.1, Version=14.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxEditors" tagprefix="dx" %>
<%@ Register assembly="DevExpress.Web.ASPxPivotGrid.v14.1, Version=14.1.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" namespace="DevExpress.Web.ASPxPivotGrid.Export" tagprefix="dx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            width: 105px;
        }
        .style3
        {
            width: 85px;
        }
    </style>
    <script type="text/javascript">
        function OnGridFocusedRowChanged() {
            // Query the server for the "EmployeeID" and "Notes" fields from the focused row 
            // The values will be returned to the OnGetRowValues() function
            //DetailNotes.SetText("Loading...");
            txttenthuoc.SetText("Loading...");
            grid.GetRowValues(grid.GetFocusedRowIndex(), 'MATHUOC;TENTHUOC', OnGetRowValues);
        }
        // Value array contains "EmployeeID" and "Notes" field values returned from the server 
        function OnGetRowValues(values) {
          txttenthuoc.SetText(values[1]);
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <dx:ASPxComboBox ID="ExportRowTypeComboBox" runat="server" AutoPostBack="True"
    Caption="Kiểu xuất dữ liệu" Theme="Metropolis">
        <Items>
            <dx:ListEditItem Text="All" Value="All" />
            <dx:ListEditItem Text="Selected" Value="Selected" />
        </Items>
    </dx:ASPxComboBox>
    <table style="width: 100%;">
        <tr>
            <td style="padding-right: 4px" class="style3">
                <dx:ASPxButton ID="btnXlsExport" runat="server" Text="Xuất ra file XLS" 
                    UseSubmitBehavior="false" onclick="btnXlsExport_Click" Theme="Metropolis">
                </dx:ASPxButton>
            </td>
            <td>
                <dx:ASPxButton ID="btnXlsxExport" runat="server" Text="Export to XLSX" 
                    UseSubmitBehavior="false" Theme="Metropolis">
                </dx:ASPxButton>
            </td>
          </tr>
        </table>
    <dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" 
        DataSourceID="ThuocLinqDataSource" EnableTheming="True" 
        KeyFieldName="MATHUOC" ClientInstanceName="grid" Width="100%">
        <ClientSideEvents FocusedRowChanged="function(s, e) {
	OnGridFocusedRowChanged();
}" />
        <TotalSummary>
            <dx:ASPxSummaryItem FieldName="total" SummaryType="Sum" />
        </TotalSummary>
        <GroupSummary>
            <dx:ASPxSummaryItem FieldName="SOLUONG" ShowInGroupFooterColumn="Số lượng" 
                SummaryType="Sum" />
            <dx:ASPxSummaryItem FieldName="Total" ShowInGroupFooterColumn="Total" 
                SummaryType="Sum" />
        </GroupSummary>
        <Columns>
            <dx:GridViewDataTextColumn FieldName="TENTHUOC" VisibleIndex="3" 
                Caption="Tên thuốc" Width="100px">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn FieldName="HOATCHAT" VisibleIndex="4" 
                Caption="Hoạt chất">
            </dx:GridViewDataTextColumn>
            <dx:GridViewCommandColumn ShowDeleteButton="True" ShowEditButton="True" 
                ShowNewButtonInHeader="True" VisibleIndex="1">
            </dx:GridViewCommandColumn>
            <dx:GridViewDataTextColumn FieldName="NGANCHUA" VisibleIndex="5" 
                Caption="Ngăn chứa">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="Nước sản xuất" FieldName="NUOCSANXUAT" 
                VisibleIndex="14">
                <PropertiesComboBox DataSourceID="NuocSXSource" TextField="TENNUOC" 
                    ValueField="MANUOC">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataComboBoxColumn Caption="Loại thuốc" FieldName="MALOAITHUOC" 
                VisibleIndex="7">
                <PropertiesComboBox DataSourceID="LoaiThuocLinqDataSource" TextField="TENLOAI" 
                    ValueField="MALOAITHUOC">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn Caption="Quy cách" FieldName="QUYCACH" 
                VisibleIndex="13">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataTextColumn Caption="Hệ số" FieldName="HESO" VisibleIndex="12">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="ĐV Nhập" FieldName="DVNHAP" 
                VisibleIndex="9">
                <PropertiesComboBox DataSourceID="DonViTinhLinqDataSource" TextField="TENDVT" 
                    ValueField="MADVT">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataComboBoxColumn Caption="ĐV Xuất" FieldName="DVXUAT" 
                VisibleIndex="11">
                <PropertiesComboBox DataSourceID="DonViTinhLinqDataSource" TextField="TENDVT" 
                    ValueField="MADVT">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn Caption="Ghi chú" FieldName="GHICHU" 
                VisibleIndex="18">
            </dx:GridViewDataTextColumn>
            <dx:GridViewDataComboBoxColumn Caption="Nhà sản xuất" FieldName="NHASANXUAT" 
                VisibleIndex="16">
                <PropertiesComboBox DataSourceID="NhaSXSource" TextField="TENNHASX" 
                    ValueField="MANHASX">
                </PropertiesComboBox>
            </dx:GridViewDataComboBoxColumn>
            <dx:GridViewDataTextColumn Caption="Điều kiện bảo quản" 
                FieldName="DIEUKIENBAOQUAN" VisibleIndex="17">
            </dx:GridViewDataTextColumn>
        </Columns>
        <SettingsBehavior AllowFocusedRow="True" />
        <SettingsPager PageSize="5">
        </SettingsPager>
        <Settings ShowFilterRow="True" ShowGroupPanel="True" ShowFooter="True" 
            ShowGroupFooter="VisibleAlways" />
         <SettingsCommandButton>
            <NewButton Text ="Thêm mới"></NewButton>
            <EditButton Text="Sửa"></EditButton>
            <DeleteButton Text="Xóa"></DeleteButton>
            <UpdateButton Text="Cập nhật"></UpdateButton>
            <CancelButton Text="Hủy"></CancelButton>
         </SettingsCommandButton>
    </dx:ASPxGridView>
     <table style="width: 100%; height: 200px" class="OptionsTable TopMargin">
      <tr>
        <td > 
            
  <dx:ASPxFormLayout ID="ASPxFormLayout1" runat="server" ColCount="2" 
                AlignItemCaptionsInAllGroups="True" Width="50%">
                <Items>
                    <dx:LayoutGroup Caption="Thông tin thuốc" ColCount="2" ColSpan="2">
                        <Items>
                            <dx:LayoutItem Caption="Tên thuốc" FieldName="TENTHUOC">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="txttenthuoc" runat="server" 
                                            ClientInstanceName="txttenthuoc" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Loại thuốc" FieldName="MALOAITHUOC">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxComboBox ID="cbLoaiThuoc" runat="server" 
                                            DataSourceID="LoaiThuocLinqDataSource" TextField="TENLOAI" 
                                            ValueField="MALOAITHUOC" ClientInstanceName="cbLoaiThuoc">
                                        </dx:ASPxComboBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Hoạt chất" ColSpan="2" FieldName="HOATCHAT" 
                                Width="100%">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="txtHoatChat" runat="server" Width="200px" 
                                            ClientInstanceName="txtHoatChat">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Ngăn chứa" ColSpan="2" FieldName="NGANCHUA" 
                                Width="100%">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="txtNganChua" runat="server" Width="170px" 
                                            ClientInstanceName="txtNganChua">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Đơn vị nhập" FieldName="DVNHAP">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxComboBox ID="cbDonViNhap" runat="server" 
                                            DataSourceID="DonViTinhLinqDataSource" TextField="TENDVT" 
                                            ValueField="MADVT" ClientInstanceName="cbDonViNhap">
                                        </dx:ASPxComboBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Đơn vị xuất" FieldName="DVXUAT">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxComboBox ID="ASPxFormLayout1_E14" runat="server" 
                                            DataSourceID="DonViTinhLinqDataSource" TextField="TENDVT" ValueField="MADVT">
                                        </dx:ASPxComboBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Hệ số" FieldName="HESO">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="xtHe" runat="server" Width="170px" 
                                            ClientInstanceName="txtHeSo">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Quy cách" FieldName="QUYCACH">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout1_E9" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Nhà sản xuất" FieldName="NHASANXUAT">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxComboBox ID="ASPxFormLayout1_E15" runat="server" 
                                            DataSourceID="NhaSXSource" TextField="TENNHASX" ValueField="MANHASX">
                                        </dx:ASPxComboBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Nước sản xuất" FieldName="NUOCSANXUAT">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxComboBox ID="ASPxFormLayout1_E16" runat="server" 
                                            DataSourceID="NuocSXSource" TextField="TENNUOC" ValueField="MANUOC">
                                        </dx:ASPxComboBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Điều kiện bảo quản" ColSpan="2" 
                                FieldName="DIEUKIENBAOQUAN" Width="100%">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout1_E12" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Ghi chú" ColSpan="2" FieldName="GHICHU" Width="100%">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout1_E13" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                        </Items>
                        <SettingsItemCaptions HorizontalAlign="Left" VerticalAlign="Middle" />
                        <SettingsItems HorizontalAlign="Right" />
                    </dx:LayoutGroup>
                </Items>
                <SettingsItems HorizontalAlign="Left" />
                <SettingsItemCaptions HorizontalAlign="Right" VerticalAlign="Middle" />
            </dx:ASPxFormLayout>
          
        </td>
        <td valign="top">
            <dx:ASPxFormLayout ID="ASPxFormLayout2" runat="server">
                <Items>
                    <dx:LayoutGroup Caption="Thông tin giá" ColCount="2">
                        <Items>
                            <dx:LayoutItem Caption="Giá nhập mới">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout2_E1" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Tỷ lệ lãi">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout2_E3" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Giá hiện hành">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout2_E2" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="VAT nhập">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout2_E4" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Giá cũ">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout2_E5" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="VAT xuất">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout2_E6" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Giá bán">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout2_E7" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                        </Items>
                    </dx:LayoutGroup>
                    <dx:LayoutGroup Caption="Cấu hình cảnh báo" ColCount="2">
                        <Items>
                            <dx:LayoutItem Caption="Số lượng cảnh báo" ColSpan="2">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout2_E8" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Cảnh báo HSD trước">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                        <dx:ASPxTextBox ID="ASPxFormLayout2_E9" runat="server" Width="170px">
                                        </dx:ASPxTextBox>
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                            <dx:LayoutItem Caption="Ngày" ShowCaption="False">
                                <LayoutItemNestedControlCollection>
                                    <dx:LayoutItemNestedControlContainer runat="server">
                                    </dx:LayoutItemNestedControlContainer>
                                </LayoutItemNestedControlCollection>
                            </dx:LayoutItem>
                        </Items>
                    </dx:LayoutGroup>
                </Items>
                <SettingsItems HorizontalAlign="Right" />
                <SettingsItemCaptions HorizontalAlign="Left" VerticalAlign="Middle" />
            </dx:ASPxFormLayout>
        </td>
        </tr>
    </table>
    <asp:LinqDataSource ID="ThuocLinqDataSource" runat="server" 
        ContextTypeName="QLHieuThuocFull.QLDUOCDataContext" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True" TableName="THUOCs">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="DonViTinhLinqDataSource" runat="server" 
        ContextTypeName="QLHieuThuocFull.QLDUOCDataContext" TableName="DVTINHs">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="NhaSXSource" runat="server" 
        ContextTypeName="QLHieuThuocFull.QLDUOCDataContext" TableName="NHASANXUATs">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="LoaiThuocLinqDataSource" runat="server" 
        ContextTypeName="QLHieuThuocFull.QLDUOCDataContext" 
        TableName="LOAITHUOCs">
    </asp:LinqDataSource>
    <asp:LinqDataSource ID="NuocSXSource" runat="server" 
        ContextTypeName="QLHieuThuocFull.QLDUOCDataContext" TableName="NUOCSANXUATs">
    </asp:LinqDataSource>
    <dx:ASPxGridViewExporter ID="gridExport" runat="server" 
        ExportedRowType="Selected" GridViewID="grid">
    </dx:ASPxGridViewExporter>
</asp:Content>
